package xyz.tanxiao.links.service.impl;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import xyz.tanxiao.links.common.enums.CommonStatusEnum;
import xyz.tanxiao.links.common.enums.DomainTypeEnum;
import xyz.tanxiao.links.entity.SlDomainManage;
import xyz.tanxiao.links.mapper.SlDomainManageMapper;
import xyz.tanxiao.links.service.SlDomainManageService;

import java.util.List;

@Slf4j
@RequiredArgsConstructor
@Service
public class SlDomainManageServiceImpl extends ServiceImpl<SlDomainManageMapper, SlDomainManage> implements SlDomainManageService {

	/**
	 * 通过域名类型获取域名信息
	 *
	 * @param type 域名类型
	 * @return 域名信息
	 */
	@Override
	public List<SlDomainManage> getDomainsByType(DomainTypeEnum type) {
		return this.list(
			Wrappers.lambdaQuery(SlDomainManage.class).eq(SlDomainManage::getType, type.getType())
		);
	}


	/**
	 * 通过域名状态获取域名信息
	 *
	 * @param status 域名状态
	 * @return 域名信息
	 */
	@Override
	public List<SlDomainManage> getDomainsByStatus(CommonStatusEnum status) {
		return this.list(
			Wrappers.lambdaQuery(SlDomainManage.class).eq(SlDomainManage::getStatus, status.getStatus())
		);
	}

}